
package za.ac.cput.peterjohn.DesignPatternPrincipals.Behavioral.Mediator.Model;


public class DollarConverter 
{
    Mediator mediator;
    public static final float DOLLAR_UNIT = 1.0f;
    public static final float EURO_UNIT = 0.7f;
    public static final float KRONA_UNIT = 0.8f;

    public DollarConverter(Mediator mediator) 
    {
        this.mediator = mediator;
        mediator.registerDollarConverter(this); 
    }
    
    public float convertEurosToDollars(float euros)
    {
        float dollars = euros * (DOLLAR_UNIT / EURO_UNIT);
        return dollars;
    }
    
    public float convertKronorToDollars(float kronor)
    {
        float dollar = kronor * (DOLLAR_UNIT / KRONA_UNIT);
        return dollar;
    }
    
    public float convertCurrencyToDollars(float amount, String unitOfCurrency)
    {
        if("krona".equalsIgnoreCase(unitOfCurrency))
            return convertKronorToDollars(amount);
        else
            return convertEurosToDollars(amount);
    }
    
}
